package com.example.demo.service;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.example.demo.entity.Laboratory;
import com.example.demo.entity.User;
import com.example.demo.mapper.LaboratoryMapper;
import com.example.demo.mapper.UserMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Service;

import java.sql.Wrapper;
import java.util.List;

@Service
public class LaboratoryService {

    @Autowired
    private LaboratoryMapper laboratoryMapper;


    /**
     * 查询实验室
     * @param laboratory
     * @return
     */

    public List<Laboratory> list(Laboratory laboratory){
        LambdaQueryWrapper<Laboratory> queryWrapper = Wrappers.lambdaQuery(laboratory);
        return laboratoryMapper.selectList(queryWrapper);
    }

    /**
     * 添加新的实验室
     * @param laboratory
     * @return
     */
    public int save(Laboratory laboratory){
        return laboratoryMapper.insert(laboratory);
    }

    /**
     * 更新实验室信息
     * @param laboratory
     * @return
     */
    public int update(Laboratory laboratory){
        return laboratoryMapper.updateById(laboratory);
    }

    public int delete(Long id){
        return laboratoryMapper.deleteById(id);
    }

    /**
     * 根据ID查询图书馆
     * @param id
     * @return
     */
    public Laboratory getById(Long id){
        return laboratoryMapper.selectById(id);
    }
}